<template>
  <div id="form">
    <m-head title="绑定微信"></m-head>
    <form class="form">
      <div>
        <input type="text" v-model="wx" autofocus>
      </div>
<button type="button" @click="bind( )" >保存</button>
    </form>
  </div>
</template>

<script>
import MHead from './MHeader'
import * as user from '../api/user'
export default {
  name: 'binding',
  components: {
    'm-head': MHead
  },
  data () {
    return {
      wx: ''
    }
  },
  methods: {
    bind () {
      user.updateUser({wx: this.wx}).then(res => {
        if (res.code == 200) {
          alert('绑定成功')
          this.$router.push('account')
        } else {
          alert('绑定失败')
        }
      })
    }
  }
}
</script>

<style scoped>
.form{
  padding: .3rem;
}
.form input{
  height: .8rem;
  display: block;
  border-bottom: 1px solid #eee;
  width: 100%;
  padding-left: .3rem;
}
.form input:focus{
  outline: 0;
}
.form button{
  display: block;
  width: 4rem;
  height: .8rem;
  line-height: .8rem;
  color: #fff;
  background: #007aff;
  border: none;
  margin: 2rem auto;
}
</style>
